class Boom{
  constructor(ctx, egg){
    this.ctx = ctx;
    this.egg = egg;
    //鸡蛋碎掉的坐标数据
    this.init = {
      x: egg.init.x-8 ,
      y: ctx.canvas.height - 106,
      w: 62,
      h: 51
    }
    //鸡蛋碎掉图片的索引
    this.index = 0;
    //控制此次鸡蛋碎掉是否结束（默认结束）
    this.status = true;
  }
  draw(animation) {
    //控制索引的变化
    
    if (this.index > 18) {
      //此次鸡蛋碎掉结束
      this.index = 18;
      this.status = false;
    }
    //绘制鸡蛋碎掉的其中一张图片
    let img = animation[this.index];
    this.ctx.drawImage(img, this.init.x, this.init.y, this.init.w, this.init.h);
    this.index += 1;
  }
  
}
export default Boom;